package chixing.day04;

import com.sun.tools.javac.Main;

import java.util.Arrays;

public class Work {
    public static void main(String[] args) {
//        1.将两个一维数组合并，并按照升序排序
        int[] a = {26,55,99,35,12};
        int[] b = {98,58,3,87,43,8};
        int[] c = new int[a.length+b.length];
        //冒泡排序把a数组排好
        int temp;
        for (int i = 0;i < a.length;i++){
            for (int j = 0;j < a.length-i-1;j++){
                if (a[j] > a[j+1] ){
                    temp = a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(a));
        //将排好序的a数组放入c数组中
        for (int i = 0;i < a.length;i++){
            c[i] = a[i];
        }
        System.out.println(Arrays.toString(c));
        //把b数组插入排序到c中
        //int[] b = {98,58,3,87,43,8};
        //遍历b数组与c数组中的元素比较
        for (int i = 0;i < b.length;i++){
            for (int j = a.length + i -1 ;j >= 0 ;j--){
                if (b[i] <= c[j]){
                    c[j+1]=c[j];
                }else {
                    c[j+1]=b[i];
                }
            }
        }
        System.out.println(Arrays.toString(c));


    }
}
